﻿Imports Microsoft.VisualBasic

Public Class clsRegEx

    Overloads Shared Function CheckEngNumStringRegEx(ByVal txtString As String, ByVal SpecialCharacter As String) As Boolean
        Dim strRegex As String = "^[a-zA-Z][a-zA-Z0-9_\." & SpecialCharacter & "]*$"
        Dim myRegex As New Regex(strRegex, RegexOptions.IgnoreCase Or RegexOptions.Multiline Or RegexOptions.Singleline Or RegexOptions.IgnorePatternWhitespace)
        Dim strTargetString As String = txtString
        Dim ReturnBoolean As Boolean = False

        For Each myMatch As Match In myRegex.Matches(strTargetString)
            If myMatch.Success Then
                ReturnBoolean = myMatch.Success
            End If
        Next

        Return ReturnBoolean
    End Function

    Overloads Shared Function CheckEngNumStringRegEx(ByVal txtString As String) As Boolean
        Dim strRegex As String = "^[a-zA-Z][a-zA-Z0-9_\.]*$"
        Dim myRegex As New Regex(strRegex, RegexOptions.IgnoreCase Or RegexOptions.Multiline Or RegexOptions.Singleline Or RegexOptions.IgnorePatternWhitespace)
        Dim strTargetString As String = txtString
        Dim ReturnBoolean As Boolean = False

        For Each myMatch As Match In myRegex.Matches(strTargetString)
            If myMatch.Success Then
                ReturnBoolean = myMatch.Success
            End If
        Next

        Return ReturnBoolean
    End Function


    Public Shared Function isFirstCapitalLetter(ByVal txtString As String) As Boolean
        Dim returnBoolean As Boolean = False
        Dim array() As Char = txtString.ToCharArray
        If array.Length > 0 Then
            If Char.IsUpper(array(0)) Then
                returnBoolean = True
            End If
        End If
        Return returnBoolean
    End Function


End Class
